import axios from "axios"

import { Guid } from './guid'


// 获取设备id
let DeviceID = localStorage.DeviceID;
if (!DeviceID) {
    DeviceID = Guid.NewGuid().ToString('D');
    localStorage.DeviceID = DeviceID;
}
let ID = DeviceID;
console.log(ID)

axios.defaults.baseURL = 'https://www.365msmk.com'


// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    config.headers={
        DeviceId:ID,
        DeviceType:"H5"
    }
    let adminToken=localStorage.getItem("adminToken")
    if(adminToken){
      config.headers.Authorization=`Bearer ${adminToken}`
    }
    
    // 在发送请求之前做些什么
    return config;
  }, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
  });
  
  export default axios